package com.cwl.aircraft;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;

/**
 * @program: cwl_aircraft
 * @description: 游戏工具类
 * @author: ChenWenLong
 * @create: 2019-11-14 10:50
 **/
public class GameUtil {

    // 工具类最好将构造器私有化。
    private GameUtil() {
    }


    /**
     * 返回指定路径文件的图片对象
     * @param path
     * @return
     */
    public static Image getImage(String path) {
        BufferedImage bi = null;
        try {
            URL u = GameUtil.class.getClassLoader().getResource(path);
            bi = ImageIO.read(u);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return bi;
    }
}
